inline creation dictionnary C#

60

inline creation dictionnary C# -

var dict = new Dictionary<string, int>
{
	{ "one", 1 },
	{ "two", 2 },
    { "three", 3 }
};

inline creation dictionnary C# -

#With C#6
var dict = new Dictionary<string, int>
{
    ["one"] = 1,
    ["two"] = 2,
    ["three"] = 3
};

Comments

Submit
0 Comments